local GuildBaseInfo = class("GuildBaseInfo")


function GuildBaseInfo:ctor()
    self._guildMemberNum = 0 -- 公会成员数目
    self._guildIconData = nil --公会图标
    self._guildName = "" --公会名称
    self._guildId = 0 --公会id
    self._serverIndex = 0 --服务器名称
    self._guildTotalPower = 0 --公会总战力
    self._highestPower = 0 --公会最高战力
    self._totalContribution = 0 --// 总贡献度
    self._totalProsperity = 0 -- 总繁荣度
    self._description = "" --公会描述
    self._lv = lv
    self._leaderName = ""
    self._leaderID = 0
end

function GuildBaseInfo:read(pbData)
    if not pbData then
        return
    end
    self._guildId = rawget(pbData, "uuid") or ""
    self._guildName = rawget(pbData, "name") or ""
    self._lv = rawget(pbData, "lv") or 0
    self._serverIndex = rawget(pbData, "server") or 0
    self._guildMemberNum = rawget(pbData, "memberNum") or 0
    self._leaderName = rawget(pbData, "leaderName") or ""
    self._leaderID = rawget(pbData, "leaderID") or 0
    self._guildIconData = self:_convertToGuildIconData(pbData)
    self._description = rawget(pbData, "description") or ""
    self._guildTotalPower = rawget(pbData, "totalCombatPower") or 0
    self._highestPower = rawget(pbData, "highestCombatPowr") or 0
    self._totalContribution = rawget(pbData, "totalContribution") or 0
    self._totalProsperity = rawget(pbData, "totalProsperity") or 0
end


function GuildBaseInfo:_convertToGuildIconData(pbData)
	local param = {
		baseIconId = pbData.flagBaseIcon,
		baseIconColor = pbData.flagBaseIconColor,
		additionIconId = pbData.flagAdditionalIcon,
		additionIconColor = pbData.flagAdditionalIconColor
    }
	return param
end

function GuildBaseInfo:getTotalPowerStr(tp)
    local unitStr = ""
    if tp == 1 then
        unitStr =  L("damageunit1")
    else
        unitStr = "w"
    end
    if self._guildTotalPower > 10000 then
        return math.floor(self._guildTotalPower/10000)..unitStr
    end
    return tostring(self._guildTotalPower)
end

function GuildBaseInfo:getGuildTotalCombatPw()
    return self._guildTotalPower
end

function GuildBaseInfo:getHighestCombatPowr()
    return self._highestPower
end


function GuildBaseInfo:getTotalProsperity()
    return self._totalProsperity
end

function GuildBaseInfo:getTotalContribution()
    return self._totalContribution
end

function GuildBaseInfo:getGuildDesc()
    return self._description
end
function GuildBaseInfo:getGuildLv()
    return self._lv
end
function GuildBaseInfo:getGuildLeaderName()
    return self._leaderName
end
function GuildBaseInfo:getLeaderId()
    return self._leaderID
end

function GuildBaseInfo:getServerName()
    return app.channelAPI:getServerNameByIndex(self._serverIndex)
end

function GuildBaseInfo:getGuildName()
    return self._guildName
end

function GuildBaseInfo:getGuildId()
    return self._guildId
end

function GuildBaseInfo:getGuildMemberNum()
    return self._guildMemberNum
end

function GuildBaseInfo:getGuildIconData()
    return self._guildIconData
end

function GuildBaseInfo:getServerIndex()
    return self._serverIndex
end

function GuildBaseInfo:isMyGuild()
    return UD:getGuildId() == self._guildId
end

return GuildBaseInfo